package driver;
import util.Util;
import gui.ChartForm;

public class Iron {
	
	public static void graphic(){
		Util.enableWebStart();
		//new MenuFrame();
        //new MainFrame();
        new ChartForm();
	}
	public static void main(String[] args) {
		graphic();
	}
    /*public static void ah(){
        try {
            double[] urmWeights = new double[]{21, 34, 11, 13, 15, 22, 32, 21};
            //double[] urmWeights = new double[]{12, 20, 7, 8, 9, 13, 19, 12};
            DmuList u = util.Util.LoadFile("PDM1.csv");
            Optimization deaOpt = new Optimization(u, 2);
            Optimizer.calculateDea(deaOpt);
            PdmOptimization pdmOpt = new PdmOptimization(u, 2, 0, urmWeights, deaOpt);
            Util.print(Arrays.toString(pdmOpt.getRelUrmWeights()));
            Util.print(Arrays.toString(pdmOpt.getOptimizationDirections()));
            Optimizer.calculatePdm(pdmOpt);
			//int[] heuristikDirections = pdmOpt.getOptimizationDirections();


            TransitionExplorer expl = 
                    new TransitionExplorer
                    (deaOpt,
                    urmWeights,
                    new PdmOptimization(u, deaOpt.getObjectiveDmu(), 0,urmWeights, deaOpt).getOptimizationDirections());
            for(PdmOptimization o:expl.getTransitionList()){
                Util.print(o.getAlpha() + "\t \t\t" + o.getProfileDistance());
            }

        } catch (CalculationException ex) {
            Logger.getLogger(Iron.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NumberFormatException ex) {
            Logger.getLogger(Iron.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Iron.class.getName()).log(Level.SEVERE, null, ex);
        }



    }
	public static void analyze() {
		DmuList u;
		String filename = "beasley.csv";
		
		try {
			double[] urmWeights = new double[]{21, 34, 11, 13, 15, 22, 32 /*,21};
			
			u = util.Util.LoadFile(filename);
			
			for(int a = 2;a<u.size();a++){
				double alpha = 0.0;
				
				//prepare Heuristik directions
				Optimization deaOpt = new Optimization(u, a);
				Optimizer.calculateDea(deaOpt);
				PdmOptimization pdmOpt = new PdmOptimization(u, a, alpha, urmWeights, deaOpt);
				Util.log("UrmWeights: " + Arrays.toString(pdmOpt.getRelUrmWeights()));
				Optimizer.calculatePdm(pdmOpt);
				int[] heuristikDirections = pdmOpt.getOptimizationDirections();
				
				
				//Util.print(pdmOpt.toString());
				
				//get upper bound for alpha
				TransitionExplorer expl = new TransitionExplorer(deaOpt, urmWeights, pdmOpt.getOptimizationDirections());
				List<PdmOptimization> list = expl.getTransitionList();
				for(PdmOptimization p:list){
					Util.log("alpha:" + p.getAlpha() + " - " + p.toString());
				}
				
				//input variables
				int iterations = 300;
				double step = (list.get(list.size()-1).getAlpha()+(list.get(list.size()-1).getAlpha()*0.1))/iterations;
				alpha = 0;
				
				//initialize filewriter
				String header = "Alpha;Anzahl;ObjectMax;ObjectHeur;MinAbstandHeur;MaxAbstandHeur;MinAbstandOpt;MaxAbstandOpt";
				Util.initializeFileWriter("RESULT_" + filename.replace('.', '_')+ "_DMU_" + a + ".csv");
				Util.writeToFile(header);
				
				
				
				String line;
				for(int i = 0;i<=iterations;i++){
					alpha = alpha + step;
					Util.log(i + " ALPHA: " + alpha);
					line = alpha +";";
					
					/*PdmOptimization heuristik = new PdmOptimization(u, a, alpha, urmWeights, heuristikDirections);
					Optimizer.calculatePdm(heuristik);
					List<PdmOptimization> optima = Tool.getBestObjectiveDirections(u, urmWeights, alpha);
					
					line += optima.size()+";" + optima.get(0).getOptimizationObjective() + ";" + heuristik.getOptimizationObjective() + ";";
					
					ArrayList<Double> externals = Tool.getDiffsToExternalVector(optima, heuristik);
					line+= externals.get(0) + ";" + externals.get(externals.size()-1);
					
					if(optima.size()>1){
						ArrayList<Double> internals = Tool.getInternalVectorDiffs(optima);
						line+= internals.get(0) + ";" + internals.get(internals.size()-1)+ ";";
					}
					
					Util.writeToFile(line);
				}
				Util.closeFileWriter();
			}
			
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (CalculationException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}*/
}
